/**
 * description：对stream_copy_logo进行重写，防止数据爆仓(也就是读取得快，写得慢的时候)
 * author：洪俊勇
 * createTime：2017/8/27
 * version:1.0.0.0
 * history:
 *   1、
 *   2、
 */
var fs = require('fs')

var readStream = fs.createReadStream('2.mp4')
var writeStream = fs.createWriteStream('2-stream.mp4')

readStream.on('data',function (chunk) {
    if(writeStream.write(chunk) === false){
        console.log('still cached')
        readStream.pause()
    }
})

readStream.on('end',function () {
    writeStream.end()
})

writeStream.on('drain',function () {
    console.log('still drain')

    readStream.resume()
})